<script>
	
	export default {
		onLaunch: function() {
			  var that=this
			  uni.login({
				  success:(res)=>{
					that.request("/api/index/wxlogin",{code:res.code,uniacid:1},"post").then(ret=>{
						uni.setStorageSync('session_key', ret.info.session_key)
						uni.setStorageSync('openid', ret.info.openid)
						uni.setStorageSync('unionid', ret.info.unionid)
						uni.setStorageSync('user_id', ret.info.user_id)
						
						var token = wx.getStorageSync('token')
						if(!token){
							// api.ajax2("wechat/token/create_token",{unionid:ret.data.unionid},function(rt){
							// 	wx.setStorageSync('token', rt.info.token)
							// })
						}else{
									
						}
					})
				  }
			})
		},
		onShow: function() {
			const updateManager = uni.getUpdateManager();
			updateManager.onCheckForUpdate(function(res) {
				if (res.hasUpdate) {
					updateManager.onUpdateReady(function() {
						  uni.showModal({
							title: '更新提示',
							content: '发现新版本，是否重启应用？',
							success: function(res) {
							  if (res.confirm) {
								updateManager.applyUpdate();
							  }
							}
						  });
					});
				}
			})
			updateManager.onUpdateFailed(function() {
			  uni.showModal({
				title: '已有新版本',
				content: '下载新版本失败，请手动删除后再进入',
			  });
			});
		},
		onHide: function() {
			console.log('App Hide')
		}
	}
</script>

<style>
	/*每个页面公共css */
</style>
